# Maintainer: David Runge <dvzrv@archlinux.org>

_name=coverage_conditional_plugin
pkgname=python-coverage-conditional-plugin
pkgver=0.9.0
pkgrel=1
pkgdesc="Conditional coverage based on any rules you define"
arch=(any)
url="https://github.com/wemake-services/coverage-conditional-plugin"
license=(MIT)
depends=(
  python
  python-coverage
  python-packaging
)
makedepends=(
  python-build
  python-installer
  python-poetry-core
  python-wheel
)
checkdepends=(
  python-pytest
  python-pytest-cov
  python-pytest-randomly
)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha256sums=('6893dab0542695dbd5ea714281dae0dfec8d0e36480ba32d839e9fa7344f8215')
b2sums=('fd6242803d7e777cf9d22c4371eace51dd97df5e4359ff250dbeb2ebd602e195cfb6d5bb7e7b532cfd09b35eeb12ce9c3527ec6ac4db19dacc106ea818f2f577')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  # ignore integration tests
  pytest -vv -c /dev/null --ignore tests/test_integration.py
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
